import request from '@/utils/request'
let api = process.env.VUE_APP_PREFIX

// ==================创建技术文件==================

// 获取创建技术文件页面初始化数据
export function getInitData () {
  // eslint-disable-next-line no-tabs
  return request({
    method: 'get',
    url: `${api}/createDocs/getInitData`
  })
}

// 编辑技术文件时，获得初始化数据
export function editInitialize (params = {
  oid: '',
  date: ''
}) {
  return request({
    method: 'get',
    url: `${api}/createDocs/editInitialize`,
    params
  })
}

// this.$axios.get('http://pdm.ideal.com/Windchill/ext/ideal/conf/dbs.xml')
export function getDbsXml () {
  return request({
    method: 'get',
    url: 'http://pdm.ideal.com/Windchill/ext/ideal/conf/dbs.xml'
  })
}

// 取号页面初始化参数
export function getNumberInitParam (params = {
  docType: ''
}) {
  return request({
    method: 'get',
    url: `${api}/createDocs/getNumberInitParam`,
    params
  })
}

// 提交编辑文档
export function editDocForm (formData) {
  return request({
    url: `${api}/createDocs/editDocForm`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 提交创建文档
export function createDocForm (formData) {
  return request({
    url: `${api}/createDocs/createDocForm`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 查询引用文档
export function getRefDocList (params = {
  docName: '',
  docNumber: '',
  limit: ''
}) {
  return request({
    url: `${api}/createDocs/getRefDocList`,
    method: 'get',
    params
  })
}

// 查询替换文档
export function getReplaceDocList (params = {
  docName: '',
  docNumber: '',
  createTimeFrom: '',
  createTimeTo: ''
}) {
  return request({
    url: `${api}/createDocs/getReplaceDocList`,
    method: 'get',
    params
  })
}

// ==================创建技术文件ECN==================

// 页面初始化时获取数据getECNInitData
export function getECNInitData (params = {
  oid: null,
  isEdit: false,
  date: null
}) {
  return request({
    url: `${api}/changeNotice/getECNInitData`,
    method: 'get',
    params
  })
}

// 查询文档列表
export function searchDocuments (params = {
  number: ''
}) {
  return request({
    url: `${api}/changeNotice/searchDocuments`,
    method: 'get',
    params
  })
}

// 创建ECN
export function createECN (params) {
  return request({
    url: `${api}/changeNotice/createECN`,
    method: 'post',
    data: params
  })
}

// 编辑ECN
export function editECN (params) {
  return request({
    url: `${api}/changeNotice/editECN`,
    method: 'post',
    data: params
  })
}

// 获取换班说明getECNDescription
export function getECNDescription (params = {
  oid: '',
  date: ''
}) {
  return request({
    url: `${api}/changeNotice/getECNDescription`,
    method: 'get',
    params
  })
}
